<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>欢迎页面-X-admin2.0</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
		<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
		<link rel="stylesheet" href="./css/font.css">
		<link rel="stylesheet" href="./css/xadmin.css">
		<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
		<script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
		<script type="text/javascript" src="./js/xadmin.js"></script>
		<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
		<!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
		<script>
			$(function() {

				$("#dosubmit").click(function() {
					reg = /(\(\d{3,4}\)|\d{3,4}-|\s)?\d{8}/;
					var reporTel = $("#reporTel").val();
					var reportName = $("#reportName").val();
					var dangerReason = $("#dangerReason").val();
					if(!reg.test(reporTel)) {
						alert("手机号码有误，请重填！");
						return false;
					} else {
						$.getJSON("modify.do", {
								"reportName": reportName,
								"reporTel": reporTel,
								"dangerReason": dangerReason
							},
							function(data) {
								if(data > 0) {
									layer.msg('修改成功!', {
										icon: 1,
										time: 10000
									});
									//刷新当前页面
									window.location.reload();
									//刷新父页面
									parent.location.reload();
								} else {
									layer.msg('操作有误!', {
										icon: 5,
										time: 1000
									});
								}
							}
						)
					}

				})
			})
		</script>
	</head>

	<body>
		<div class="x-body">
			<table class="layui-table">
				<form class="layui-form" action="#" method="post">
					<tr>
						<td style="width: 110px;"><span class="x-red">*</span>报案号</td>
						<td colspan="2">${sessionScope.reportInfo.reportNo}</td>
						<td style="width: 110px;"><span class="x-red">*</span>报案人</td>
						<td colspan="2"><input type="text" id="reportName" name="reportName" required="" lay-verify="email" autocomplete="off" class="layui-input" value="${sessionScope.reportInfo.reportName}"></td>

					</tr>
					<tr>
						<td style="width: 110px;"><span class="x-red">*</span>报案时间</td>
						<td colspan="2">
							<fmt:formatDate value="${sessionScope.reportInfo.reportTime}" pattern="yyyy-MM-dd" />
						</td>
						<td style="width: 110px;"><span class="x-red">*</span>报案电话</td>
						<td colspan="2"><input type="text" id="reporTel" name="reporTel" required="" lay-verify="email" autocomplete="off" class="layui-input" value="${sessionScope.reportInfo.reporTel}"></td>
					</tr>
					<tr>
						<td style="width: 110px;"><span class="x-red">*</span>出险地点</td>
						<td colspan="2">${sessionScope.reportInfo.dangerAddress}</td>
						<td style="width: 110px;"><span class="x-red">*</span>出险原因</td>
						<td colspan="2"><input type="text" id="dangerReason" name="dangerReason" required="" lay-verify="email" autocomplete="off" class="layui-input" value="${sessionScope.reportInfo.dangerReason}"></td>
					</tr>

					<tr>
						<td style="width: 110px;"><span class="x-red">*</span>查勘员</td>
						<td colspan="2">${sessionScope.name}</td>
						<td style="width: 110px;"><span class="x-red">*</span>接案员</td>
						<td colspan="2">${sessionScope.serviceName}</td>
					</tr>
					<tr>
						<td colspan="6"><input style="float: right" type="button" id="dosubmit" class="layui-btn" value="确认修改" /></td>
					</tr>
				</form>
			</table>
		</div>
		<script>
			layui.use(['form', 'layer'], function() {
				$ = layui.jquery;
				var form = layui.form,
					layer = layui.layer;

				//自定义验证规则
				form.verify({
					nikename: function(value) {
						if(value.length < 5) {
							return '昵称至少得5个字符啊';
						}
					},
					pass: [/(.+){6,12}$/, '密码必须6到12位'],
					repass: function(value) {
						if($('#L_pass').val() != $('#L_repass').val()) {
							return '两次密码不一致';
						}
					}
				});

				//监听提交
				form.on('submit(add)', function(data) {
					console.log(data);
					//发异步，把数据提交给php
					layer.alert("增加成功", {
						icon: 6
					}, function() {
						// 获得frame索引
						var index = parent.layer.getFrameIndex(window.name);
						//关闭当前frame
						parent.layer.close(index);
					});
					return false;
				});

			});
		</script>
		<script>
			var _hmt = _hmt || [];
			(function() {
				var hm = document.createElement("script");
				hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
				var s = document.getElementsByTagName("script")[0];
				s.parentNode.insertBefore(hm, s);
			})();
		</script>
	</body>

</html>